import 'package:efood_multivendor/util/dimensions.dart';
import 'package:efood_multivendor/util/styles.dart';
import 'package:efood_multivendor/data/model/response/faq_model.dart';
import 'package:efood_multivendor/view/base/custom_app_bar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class FAQScreen extends StatefulWidget {
  const FAQScreen({Key? key}) : super(key: key);

  @override
  State<FAQScreen> createState() => _FAQScreenState();
}

class _FAQScreenState extends State<FAQScreen> {
  List<FAQModel> data = [];

  @override
  void initState() {
    dataList.forEach((element) {
      data.add(FAQModel.fromJson(element));
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.white,
        appBar: CustomAppBar(title: 'faq'.tr),
        body: Container(
            padding: const EdgeInsets.all(Dimensions.PADDING_SIZE_LARGE),
            width: Dimensions.WEB_MAX_WIDTH,
            child: SingleChildScrollView(
              physics: AlwaysScrollableScrollPhysics(),
              child: Column(
                children: [
                  Center(
                      child: Text(
                    'frequently'.tr,
                    style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
                  )),
                  ListView.builder(
                    shrinkWrap: true,
                    physics: NeverScrollableScrollPhysics(),
                    itemCount: data.length,
                    itemBuilder: (context, index) {
                      return Column(
                        children: [
                          index == 0
                              ? Divider(
                                  thickness: 1.5,
                                )
                              : SizedBox(),
                          Theme(
                            data: Theme.of(context)
                                .copyWith(dividerColor: Colors.transparent),
                            child: ExpansionTile(
                              title: Text(
                                data[index].question?.tr ?? '',
                                style: TextStyle(
                                    fontSize: 16, fontWeight: FontWeight.bold),
                              ),
                              childrenPadding: EdgeInsets.all(8.0),
                              children: [
                                Text(
                                  data[index].answer?.tr ?? '',
                                  style: sfRegular,
                                )
                              ],
                            ),
                          ),
                          Divider(
                            thickness: 1.5,
                          )
                        ],
                      );
                    },
                  ),
                ],
              ),
            )));
  }
}
